package com.cqwshzj.util;/**
 * @Description:
 * @Auther: Huang Zhijin
 * @Version: 1.0.0
 * @Date: 2021/4/7 19:50
 */

/**
 *
 * 〈〉
 *
 * @author Huang Zhijin
 * @create 2021/4/7
 * @since 1.0.0
 */
public class ExceptionUtil {

	/**
	 * 获取指定深度的异常的堆栈信息
	 * @param e
	 * @return
	 */
	public static String getStackTraceStringOfException(Exception e){
		if (e == null || e.getStackTrace().length == 0 ) {
			return "";
		}
		StringBuilder sb = new StringBuilder();
		int maxDeep = 6;
		for (int i = 0; i <= maxDeep; i++) {
			if ( i > 0 ){
				sb.append( CrontabUtil.CHAR_SPACE );
			}
			sb.append( e.getStackTrace()[i].toString() );
		}
		return sb.toString();

	}

}
